package edu.kpi.pzks2.ui;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JToolBar;

import edu.kpi.pzks2.ui.MainFrame.LoadLabel;

@SuppressWarnings("serial")
public class GraphToolBar extends JToolBar {
    public GraphToolBar(final GraphEditor editor, final LoadLabel loadLabel) {
        setLayout(new FlowLayout(FlowLayout.LEFT));
        
        final JButton cursorButton = new JButton(MainFrame.createImageIcon("/cursor.png"));
        cursorButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                editor.setPickingMode();
            }
        });
        
        final JButton nodeButton = new JButton(MainFrame.createImageIcon("/node.png"));
        nodeButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                editor.setEditingMode();
            }
        });

        final JButton validButton = new JButton(MainFrame.createImageIcon("/validation.png"));
        validButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                loadLabel.setLoaded(editor.isGraphValid());
            }
        });
        
        final JButton statisticsButton = new JButton(MainFrame.createImageIcon("/statistics.png"));
        statisticsButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                editor.isGraphValid();
            }
        });
        
        add(cursorButton);
        add(nodeButton);
        add(validButton);
        add(statisticsButton);
    }
}
